﻿@{
    ViewBag.Title = "回访列表";
    Layout = "~/Areas/IM/Views/Shared/_Layout.cshtml";
}

@section Scripts{
    <script type="text/javascript">
        $(document).ready(function () {

            RevistMainGrid();
        });

        $(window).resize(function () {
            $.setGridWithSearchBar("#TableForm", "#tbb", "#RevistOperategrid");
        });
        function RevistMainGrid() {
            $('#RevistOperategrid').datagrid({
                width: 'auto',
                height: 'auto',
                fitColumns: false, //真正的自动展开/收缩列的大小，以适应网格的宽度，防止水平滚动。
                collapsible: true,
                loadMsg: '数据加载中,请稍后……',
                singleSelect: true,
                url: '@Url.Content("~/DD/Revisit/GetRevistMain")',
                striped: true,

                pagination: true,//启用分页，默认每页10行
                rownumbers: true,//显示页码，默认 提供 10 - 50 的页容量选择下拉框
                pageSize: 15,//设置 页容量5
                pageList: [10, 15, 20],//设置 页容量下拉框
                frozenColumns: [[
                    { field: "ID", hidden: true },
                     {
                         field: "detail", title: "明细", width: '5%', align: "center",


                         formatter: function (value, row, index) {
                             var ifOperated = -1;
                             return '<a  class="linkURLcls" onclick="openDetailURL(\'' + row.ID + '\',\'' + ifOperated + '\');"  href="javascript:void(0)">明细</a>';
                         }

                     },
                      {
                          field: "operate", title: "办理", width: '5%', align: "center",
                          formatter: function (value, row, index) {
                              return '<a  class="linkURL" onclick="openOperateURL(\'' + row.ID + '\');"  href="javascript:void(0)">办理</a>';
                          }

                      },
                         {
                             field: "CompleteRate", title: "回访进度", width: '12%', align: "center",
                             formatter: formatProgress
                         },
                      { field: "CompleteNumber", title: "已回访", width: '5%', align: "center" },
                    { field: "UnfinishedNumber", title: "未完成", width: '5%', align: "center" },
                     { field: "FillPerson", title: "交办人", width: '6%', align: "center" },
                     { field: "FillTime", title: "交办时间", width: '12%', align: "center", formatter: $.formatTime },
               { field: "FillDate", title: "任务日期", width: '8%', align: "center", formatter: $.formatDate },
                   // { field: "FillPerson", title: "填报人", width: '6%', align: "center" },
                    { field: "FillDepartment", title: "填报部门", width: '9%', align: "center" },
                     { field: "RevisitDeclare", title: "报表说明", width: '50%', align: "left" }
                ]],
                onLoadSuccess: function (data) {

                    $('.linkURLcls').linkbutton({
                        text: '明细',
                        plain: true,
                        iconCls: 'icon-search'
                    });

                    $('.linkURL').linkbutton({
                        text: '办理',
                        plain: true,
                        iconCls: 'icon-custom-cWuZiWeiHu'
                    });
                }
            });
            $.setGridWithSearchBar("#TableForm", "#tbb", "#RevistOperategrid");
        }

        function formatProgress(value) {
            if (value) {
                var s = '<div style="width:100%;border:1px solid #ccc">' +
		    			'<div style="width:' + value + '%;background:#BCEE68;color:#262626">' + value + '%' + '</div>'
                '</div>';
                return s;
            } else {
                return '';
            }
        }

        function openDetailURL(rowid, ifOperated) {

            var url = '@Url.Content("~/DD/Revisit/RevisitOperateDetailList/?RowID=")' + rowid + '&ifOperated=' + ifOperated;
            window.open(url);
        }
        function openOperateURL(rowid) {

            var url = '@Url.Content("~/DD/Revisit/RevisitOperateDetail/?RowID=")' + rowid;
            window.open(url);
        }


    </script>
}

<div id="TableForm" class="easyui-layout" style="width:auto; height: auto; margin-left: auto; margin-right: auto">
    <div data-options="region:'center',title:'回访',iconCls:'icon-custom-cPrice'">
        <div id="tbb" style="padding: 5px; height: auto">
        </div>
        <div data-options="region:'center'" style="background: #fafafa; overflow: hidden">
            <table id="RevistOperategrid" border="0"></table>
        </div>
    </div>
</div>
